<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="12">
            <a-form-model-item label="应聘岗位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyPosition">
              <j-search-select
                :disabled="formDisabled"
                v-model="model.applyPosition"
                dict="sys_position,name,id,del_flag = 0 and audit_status=2"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="期望薪资（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="expectedSalary">
              <a-input :disabled="formDisabled" v-model="model.expectedSalary" placeholder="请输入期望薪资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item
              label="期望工作地点"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="expectedWorkAddress"
            >
              <j-multi-select-tag
                :disabled="formDisabled"
                type="checkbox"
                v-model="model.expectedWorkAddress"
                dictCode="expected_work_address"
                placeholder="请选择期望工作地点"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="应聘现况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyStatus">
              <j-dict-select-tag
                :disabled="formDisabled"
                type="radio"
                v-model="model.applyStatus"
                dictCode="apply_status"
                placeholder="请选择应聘现况"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              label="预计到岗时间"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="expectedArrival"
            >
              <j-date
                :disabled="formDisabled"
                placeholder="请选择预计到岗时间"
                v-model="model.expectedArrival"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-collapse v-model="activeKey">
          <a-collapse-panel key="1" header="基础信息">
            <a-row :gutter="48">
              <a-col :span="8">
                <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
                  <a-input :disabled="formDisabled" v-model="model.name" placeholder="请输入姓名" @change="handleNameChage"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gender">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.gender"
                    dictCode="sex"
                    placeholder="请选择性别"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="民族" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="national">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.national"
                    dictCode="national"
                    placeholder="请选择民族"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="籍贯" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nativePlace">
                  <j-area-linkage :disabled="formDisabled" type="cascader" v-model="model.nativePlace" placeholder="请选择籍贯"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="出生日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="birthDate">
                  <!-- <j-date
                    :disabled="formDisabled"
                    placeholder="请选择出生日期"
                    v-model="model.birthDate"
                    style="width: 100%"
                  /> -->
                  <a-date-picker
                    disabled
                    placeholder="请选择出生日期"
                    v-model="model.birthDate"
                    :showTime="false"
                    format="YYYY-MM-DD"
                    valueFormat="YYYY-MM-DD"
                    style="width: 100%"
                    :disabled-date="(current) => current && current > moment().endOf('day')"
                    :getCalendarContainer="(node) => node.parentNode"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="身份证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardNo">
                  <a-input :disabled="formDisabled" v-model="model.idCardNo" placeholder="请输入身份证号" @input="inputIdCardNo"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="工作年限" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workTime">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.workTime"
                    dictCode="work_time"
                    placeholder="请选择工作年限"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="婚姻状况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maritalStatus">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.maritalStatus"
                    dictCode="marital_status"
                    placeholder="请选择婚姻状况"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="身高" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="height">
                  <a-input :disabled="formDisabled" v-model="model.height" placeholder="请输入身高"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="政治面貌"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="politicalLandscape"
                >
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.politicalLandscape"
                    dictCode="political_landscape"
                    placeholder="请选择政治面貌"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="是否有家族遗传病"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasFamilyGeneticHistory"
                >
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasFamilyGeneticHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择是否有家族遗传病"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="是否有传染病史"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="geneticHistory"
                >
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.geneticHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择是否有传染病史"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="血型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bloodType">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.bloodType"
                    dictCode="blood_type"
                    placeholder="请选择血型"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="是否有既往病史"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasPastMedicalHistory"
                >
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasPastMedicalHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择是否有既往病史"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="是否有犯罪记录"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasCriminalRecord"
                >
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasCriminalRecord"
                    dictCode="YES_OR_NO"
                    placeholder="请选择是否有犯罪记录"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="特长和爱好" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hobby">
                  <a-input :disabled="formDisabled" v-model="model.hobby" placeholder="请输入特长和爱好"></a-input>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="2" header="资历状况">
            <!-- <ErpHrApplyQualificationsInfoForm ref="qualificationsInfo" @ok="handleOk($event,'qualificationsInfo')"></ErpHrApplyQualificationsInfoForm> -->
            <a-row :gutter="24">
              <a-col :span="8">
                <a-form-model-item label="外语水平" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.foreignLanguageLevel">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.qualificationsInfo.foreignLanguageLevel" dictCode="foreign_language_level" placeholder="请选择外语水平" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="计算机能力" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.computerCapability">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.qualificationsInfo.computerCapability" dictCode="computer_capability" placeholder="请选择计算机能力" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="有无驾照" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.hasDrivingLicense">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.qualificationsInfo.hasDrivingLicense" dictCode="YES_OR_NO" placeholder="请选择有无驾照" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="资格证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.qualification">
                  <a-input :disabled="formDisabled" v-model="model.qualificationsInfo.qualification" placeholder="请输入资格证书"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="职称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.professional">
                  <a-input :disabled="formDisabled" v-model="model.qualificationsInfo.professional" placeholder="请输入职称"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="毕业院校" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.graduatedFrom">
                  <a-input :disabled="formDisabled" v-model="model.qualificationsInfo.graduatedFrom" placeholder="请输入毕业院校"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="专业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.major">
                  <a-input :disabled="formDisabled" v-model="model.qualificationsInfo.major" placeholder="请输入专业"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="毕业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.graduationDate">
                  <j-date :disabled="formDisabled" placeholder="请选择毕业时间" v-model="model.qualificationsInfo.graduationDate"  style="width: 100%" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="最高学历" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.highestDegree">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.qualificationsInfo.highestDegree" dictCode="highest_degree" placeholder="请选择最高学历" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="教育方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualificationsInfo.educationalMode">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.qualificationsInfo.educationalMode" dictCode="educational_mode" placeholder="请选择教育方式" />
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="3" header="联系信息">
            <!-- <erp-hr-apply-contact-info-form ref="contactInfo" @ok="handleOk($event,'contactInfo')"></erp-hr-apply-contact-info-form> -->
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.mobile">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.mobile" placeholder="请输入手机号"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="紧急联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.fixedPerson">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.fixedPerson" placeholder="请输入紧急联系人"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="紧急联系人方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.fixedTel">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.fixedTel" placeholder="请输入紧急联系人方式"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="12">
                <a-form-model-item label="电子邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.email">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.email" placeholder="请输入电子邮箱"  ></a-input>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="12">
                <a-form-model-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.postCode">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.postCode" placeholder="请输入邮政编码"  ></a-input>
                </a-form-model-item>
              </a-col> -->
              <a-col :span="24">
                <a-form-model-item label="身份证地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.idCardAddress">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.idCardAddress" placeholder="请输入身份证地址"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="现居地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.currentAddress">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.currentAddress" placeholder="请输入现居地址"  ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="户籍地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.householdAddress">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.householdAddress" placeholder="请输入户籍地址"  ></a-input>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="4" header="家庭成员与社会关系">
            <ErpHrApplyFamilySocialInfoList :newData="model.familySocialList" @delete="listDelete($event,'familySocialList')" @ok="listOk($event,'familySocialList')" :disabledButton="formDisabled"></ErpHrApplyFamilySocialInfoList>
          </a-collapse-panel>
          <a-collapse-panel key="5" header="工作经历（必填）">
<!--            <a-checkbox style="margin-left: 20px" :checked="isNoWorkHistoryChecked" :disabled="formDisabled" @change="onIsNoWorkHistoryChange" > 无工作经历</a-checkbox>-->
            <j-multi-select-tag
              :disabled="formDisabled"
              type="checkbox"
              v-model="model.isNoWorkHistory"
              dictCode="is_no_work_history"
            />
            <ErpHrApplyWorkHistoryList :newData="model.workHistoryList" @delete="listDelete($event,'workHistoryList')" @ok="listOk($event,'workHistoryList')" :disabledButton="formDisabled"></ErpHrApplyWorkHistoryList>
          </a-collapse-panel>
          <a-collapse-panel key="6" header="教育经历（必填）">
            <ErpHrApplyEducationList :newData="model.educationList" @delete="listDelete($event,'educationList')" @ok="listOk($event,'educationList')" :disabledButton="formDisabled"></ErpHrApplyEducationList>
          </a-collapse-panel>
          <!-- <a-collapse-panel key="7" header="培训经历">
            <ErpHrApplyTrainingList :newData="model.trainingList" @delete="listDelete($event,'trainingList')" @ok="listOk($event,'trainingList')" :disabledButton="formDisabled"></ErpHrApplyTrainingList>
          </a-collapse-panel>
          <a-collapse-panel key="8" header="奖惩档案">
            <ErpHrApplyRewardPunishFileList :newData="model.rewardPunishList" @delete="listDelete($event,'rewardPunishList')" @ok="listOk($event,'rewardPunishList')" :disabledButton="formDisabled"></ErpHrApplyRewardPunishFileList>
          </a-collapse-panel> -->
          <a-collapse-panel key="9" header="其他信息自述">
            <a-descriptions title="" bordered :column="1">
              <a-descriptions-item label="1.您对应聘岗位的理解？">
                <a-input :disabled="formDisabled" v-model="model.otherInfo.positionUnderstandQuestion" placeholder="请输入应聘岗位的理解"></a-input>
              </a-descriptions-item>
              <a-descriptions-item label="2.您的性格特点？">
                <a-input :disabled="formDisabled" v-model="model.otherInfo.dispositionQuestion" placeholder="请输入性格特点"></a-input>
              </a-descriptions-item>
              <a-descriptions-item label="3.公司内有无亲属，姓名.部门？">
                <a-input :disabled="formDisabled" v-model="model.otherInfo.relationshipQuestion" placeholder="请输入公司是否有无亲属"></a-input>
              </a-descriptions-item>
              <a-descriptions-item label="4.档案及社保关系？">
                <a-input :disabled="formDisabled" v-model="model.otherInfo.docQuestion" placeholder="请输入档案及社保关系"></a-input>
              </a-descriptions-item>
              <a-descriptions-item label="5.招聘信息来源？">
                <a-input :disabled="formDisabled" v-model="model.otherInfo.applyQuestion" placeholder="请输入招聘信息来源"></a-input>
              </a-descriptions-item>
            </a-descriptions>
          </a-collapse-panel>
        </a-collapse>
        <a-row :gutter="24" style="border: 1px solid #d9d9d9;border-radius: 0 0 4px 4px;padding: 20px;margin: 20px 0">
          <a-col :span="12">
            <h3>申请人声明：</h3>
            <p>本人承诺保证所填资料真实，如入职后发现所填写资料不真实，公司有权对本人进行解除劳动合同处理，并不做任何赔偿及补偿。</p>
          </a-col>
          <a-col :span="12">
            <div class="statement">
              <a-checkbox :checked="checked" :disabled="formDisabled" @change="onAggreChange" style="font-size: 14px">我已阅读并保证所填信息真实有效</a-checkbox>
              <div class="statement-p">签名：{{ model.otherInfo.applyName }}</div>
              <div class="statement-p">日期：{{ model.otherInfo.applyDate }}</div>
            </div>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import moment from 'moment'
// import { validateDuplicateValue } from '@/utils/util'
import ErpHrApplyContactInfoForm from './ErpHrApplyContactInfoForm.vue'
import ErpHrApplyQualificationsInfoForm from './ErpHrApplyQualificationsInfoForm.vue'
import JSearchSelect from './JSearchSelect.vue'
import ErpHrApplyFamilySocialInfoList from '../ErpHrApplyFamilySocialInfoList.vue'
import ErpHrApplyEducationList from '../ErpHrApplyEducationList.vue'
import ErpHrApplyTrainingList from '../ErpHrApplyTrainingList.vue'
import ErpHrApplyRewardPunishFileList from '../ErpHrApplyRewardPunishFileList.vue'
import ErpHrApplyWorkHistoryList from '../ErpHrApplyWorkHistoryList.vue'

export default {
  name: 'ErpHrApplyRegisterBillForm',
  components: { 
    ErpHrApplyContactInfoForm,
    ErpHrApplyQualificationsInfoForm,
    ErpHrApplyFamilySocialInfoList,
    ErpHrApplyEducationList,
    ErpHrApplyTrainingList,
    ErpHrApplyRewardPunishFileList,
    ErpHrApplyWorkHistoryList,
    JSearchSelect
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      model: {
        isNoWorkHistory: '0',
        otherInfo: {},
        contactInfo: {},
        educationList: [],
        familySocialList:[],
        qualificationsInfo: {},
        rewardPunishList: [],
        trainingList:[],
        workHistoryList:[]
      },
      labelCol: {},
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 24 },
      },
      confirmLoading: false,
      validatorRules: {
        applyPosition: [{ required: true, message: '请选择应聘岗位'}],
        expectedSalary: [{ required: true, pattern: /^[1-9]\d*$/, message: '请输入正确期望薪资' }],
        expectedWorkAddress: [{ required: true, message: '请选择期望工作地点' }],
        applyStatus: [{ required: true, message: '请选择应聘现况' }],
        expectedArrival: [{ required: true, message: '请选择预计到岗时间'}],
        name: [{ required: true, message: '请输入姓名' }],
        gender: [{ required: true, message: '请选择性别'}],
        national: [{ required: true, message: '请选择民族' }],
        nativePlace: [{ required: true, message: '请选择籍贯'}],
        // birthDate: [{ required: true, message: '请选择出生日期', trigger: 'change' }],
        idCardNo: [{ required: true, pattern: /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/, message: '请输入正确身份证号' }],
        workTime: [{ required: true, message: '请选择工作年限' }],
        maritalStatus: [{ required: true, message: '请选择婚姻状况'}],
        // height: [{ required: true, message: '请输入身高', trigger: 'blur' }],
        politicalLandscape: [{ required: true, message: '请选择政治面貌' }],
        hasFamilyGeneticHistory: [{ required: true, message: '请选择是否有家族遗传病' }],
        geneticHistory: [{ required: true, message: '请选择是否有传染病史' }],
        // bloodType: [{ required: true, message: '请选择血型', trigger: 'change' }],
        // hasPastMedicalHistory: [{ required: true, message: '请选择是否有既往病史', trigger: 'change' }],
        // hasCriminalRecord: [{ required: true, message: '请选择是否有犯罪记录', trigger: 'change' }],
        // hobby: [{ required: true, message: '请输入特长和爱好', trigger: 'blur' }],
        qualificationsInfo: {
          // foreignLanguageLevel: [{ required: true, message: '请选择外语水平' }],
          // computerCapability: [{ required: true, message: '请选择计算机能力'}],
          // hasDrivingLicense: [{ required: true, message: '请选择有无驾照' }],
          // qualification: [{ required: true, message: '请输入资格证书'}],
          graduatedFrom: [{ required: true, message: '请输入毕业院校' }],
          major: [{ required: true, message: '请输入专业', trigger: 'blur' }],
          graduationDate: [{ required: true, message: '请选择毕业时间', trigger: 'change' }],
          highestDegree: [{ required: true, message: '请选择最高学历' }],
          educationalMode: [{ required: true, message: '请选择教育方式' }],
        },
        contactInfo: {
          // mobile: [{ required: true, pattern: /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/, message: '请输入正确手机号' }],
          fixedPerson: [{ required: true, message: '请输入紧急联系人'}],
          mobile: [{ required: true, pattern: /(^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$)|(^\/$)/, message: '请输入正确手机号' }],
          fixedTel: [{ required: true, pattern: /(^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$)|(^\/$)/, message: '请输入正确紧急联系人方式' }],
          // fixedTel: [{ required: true, pattern: /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/, message: '请输入正确紧急联系人方式' }],
          email: [{ required: true, pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/, message: '请输入正确电子邮箱' }],
          idCardAddress: [{ required: true, message: '请输入身份证地址'}],
          currentAddress: [{ required: true, message: '请输入现居地址'}],
          householdAddress: [{ required: true, message: '请输入户籍地址'}],
        },
        // otherInfo: {
        //   agreeStatus: [{ required: true, message: '请选择是否同意' }],
        // }
      },
      url: {
        add: '/api/erp/hr/apply/erpHrApplyRegisterBill/add',
        edit: '/api/erp/hr/apply/erpHrApplyRegisterBill/edit',
        queryById: '/api/erp/hr/apply/erpHrApplyRegisterBill/queryById',
      },
      activeKey: ['1', '2', '3','4','5','6','7','8','9'],
      checked: false
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    moment,
    inputIdCardNo(){
      if(this.model.idCardNo){
        let idCardNo=this.model.idCardNo;
        if(idCardNo.length>=18){
          let birthDate=idCardNo.substr(6,4)+"-"+idCardNo.substr(10,2)+"-"+idCardNo.substr(12,2);
          this.$set(this.model,"birthDate",birthDate);
        }else{
          this.$set(this.model,"birthDate",null);
        }
      }else{
        this.$set(this.model,"birthDate",null);
      }
    },
    onAggreChange(e){
      this.checked = true
      this.model.otherInfo.agreeStatus = '1'
    },
    handleNameChage(e){
      this.model.otherInfo.applyName = e.target.value
    },
    listOk(val,key){
      console.log(val);
      this.model[key] = val
    },
    listDelete(val,key){
      console.log(val);
      this.model[key] = val
    },
    add() {
      this.$set(this.modelDefault,'otherInfo',{})
      this.$set(this.modelDefault,'contactInfo',{})
      this.$set(this.modelDefault,'qualificationsInfo',{})
      this.$set(this.modelDefault,'educationList',[])
      this.$set(this.modelDefault,'familySocialList',[])
      this.$set(this.modelDefault,'trainingList',[])
      this.$set(this.modelDefault,'workHistoryList',[])
      this.$set(this.modelDefault,'rewardPunishList',[])
      this.edit(this.modelDefault);
    },
    edit(record) {
      this.$refs.form.resetFields()
      if(record.id){
        getAction(this.url.queryById,{ id: record.id }).then(res => {
          console.log(res);
          if(res.success){
            this.model = Object.assign({}, res.result)
            this.checked = true
            this.model.otherInfo.applyName = this.model.otherInfo.applyName?this.model.otherInfo.applyName:this.model.name
          }
        })
      }else{
        this.model = Object.assign({}, record);
        this.model.otherInfo.applyDate = moment(new Date().getTime()).format('YYYY-MM-DD')
        this.$set(this.model,'birthDate',null)
        this.checked = false
      }
      this.visible = true
    },
    showMessage(){
      this.$message.warning()
    },
    submitForm() {
      const that = this
      // 触发表单验证
      
      this.$refs.form.validate((valid) => {
        if (this.model.isNoWorkHistory != '1'){
          if(that.model.workHistoryList.length === 0) {
            this.$message.warning('请添加工作经历')
            return
          }
        }
        if(that.model.educationList.length === 0) {
          this.$message.warning('请添加教育经历')
          return
        }
        console.log(this.model);
        if (valid) {
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          httpAction(httpurl, this.model, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
            })
        }
      })
    },
  },
}
</script>
<style lang="less" scoped>
.statement{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  .statement-p{
    width: 242px;
    line-height: 1.5;
    font-size: 14px;
  }
}
</style>
